// 获取元素
// 昵称
let userTest = document.querySelector('.users .test')
let user = document.querySelector('.user')
let userCont = document.querySelector('.users .cont')


user.addEventListener('input', function () {
    userTest.style.display = "block"
    // userCont.style.display="block"
})
user.addEventListener('blur', function () {
    // userTest.style.display="block"
    userCont.style.display = "block"
})
userTest.addEventListener('click', function () {
    userTest.style.display = "none"
    user.value = ''

})
// 手机号
let telTest = document.querySelector('.tels .test')
let tel = document.querySelector('.tel')
let telCont = document.querySelector('.tels .cont')


tel.addEventListener('input', function () {
    telTest.style.display = "block"
})
tel.addEventListener('blur', function () {
    telCont.style.display = "block"
})
telTest.addEventListener('click', function () {
    telTest.style.display = "none"
    tel.value = ''

})

// 验证
let checkTest = document.querySelector('.checks .test')
let check = document.querySelector('.check')
let checkCont = document.querySelector('.checks .cont')


check.addEventListener('input', function () {
    checkTest.style.display = "block"
})
check.addEventListener('blur', function () {
    checkCont.style.display = "block"
})
checkTest.addEventListener('click', function () {
    checkTest.style.display = "none"
    check.value = ''

})

// 密码
let pwdTest = document.querySelector('.pwds .test')
let pwd = document.querySelector('.pwd')
let pwdCont = document.querySelector('.pwds .cont')


pwd.addEventListener('input', function () {
    pwdTest.style.display = "block"
})
pwd.addEventListener('blur', function () {
    pwdCont.style.display = "block"
})
pwdTest.addEventListener('click', function () {
    pwdTest.style.display = "none"
    pwd.value = ''

})

// 注册
let checkbox = document.querySelector('.checkbox')
let butt = document.querySelector('.butt')
checkbox.addEventListener('click', function () {
    if (checkbox.checked) {
        butt.style.backgroundColor = "#00bdff"
        butt.style.color = "white"
    } else {
        butt.style.backgroundColor = ""
        butt.style.color = ""

    }
})
// let reg = /^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$/;
//     return reg.test(phoneNum);

let regArr = [
    /^[a-zA-Z][a-zA-Z0-9_]{5,11}$/,
    /^1[345678][0-9]{9}$/,
    /^[a-zA-Z][a-zA-Z0-9_]{3}$/,
    /^[a-zA-Z][a-zA-Z0-9_]{5,11}$/

]
let Cont=document.querySelectorAll('.cont')
// console.log(Cont)
let reCont = document.querySelectorAll('#re-cont')
butt.addEventListener('click', function () {
    for (let i = 0; i < reCont.length; i++) {
        let bool = regArr[i].test(reCont[i].value)
    //    console.log(bool)
    if(bool){
        // userCont.style.display = "none"
        // telCont.style.display = "none"
        // checkCont.style.display = "none"
        // pwdCont.style.display = "none"
     Cont[i].style.display='none'

    }else{
        // userCont.style.display = "block"
        // telCont.style.display = "block"
        // checkCont.style.display = "block"
        // pwdCont.style.display = "block"
        Cont[i].style.display='block'
    return

    }

        }
       
})
